package com.jkl.controller.home;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.jkl.entity.BaseResponseDTO;
import com.jkl.entity.home.HomeRequestEntity;
import com.jkl.entity.home.MainIndexResponseEntity;
import com.jkl.service.home.mainIndexInter.MainIndexChangService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * @author zjj
 * @date 2019/12/23
 * @Description ${描述一个类的相关信息}
 */
@RestController
@RequestMapping("/jky/home/indexChang")
@Slf4j
public class MainIndexChangController {
    @Autowired
    MainIndexChangService mainIndexChangService;

    /**
     * 处理总量分析
     */
    @PostMapping("/processTotalAnalysis")
    public BaseResponseDTO processTotalAnalysis(@RequestBody HomeRequestEntity homeRequestEntity) {
        BaseResponseDTO returnData = new BaseResponseDTO();
        MainIndexResponseEntity productionAmountAnalysis = mainIndexChangService.getProductionAmountAnalysis(homeRequestEntity);
        JSONObject jsonObject = JSONObject.parseObject(JSON.toJSONString(productionAmountAnalysis));
        returnData.setReturnData(jsonObject);
        return returnData;
    }

    /**
     * 处置量分析
     */
    @PostMapping("/disposalAnalysis")
    public BaseResponseDTO disposalAnalysis(@RequestBody HomeRequestEntity homeRequestEntity) {
        BaseResponseDTO returnData = new BaseResponseDTO();
        MainIndexResponseEntity cityGarbageAndRate = mainIndexChangService.disposalAnalysis(homeRequestEntity);
        JSONObject jsonObject = JSONObject.parseObject(JSON.toJSONString(cityGarbageAndRate));
        returnData.setReturnData(jsonObject);
        return returnData;
    }



    /**
     * 回收利用折线
     */
    @PostMapping("/recyclePolyline")
    public BaseResponseDTO recyclePolyline(@RequestBody HomeRequestEntity homeRequestEntity) {
        BaseResponseDTO returnData = new BaseResponseDTO();
        MainIndexResponseEntity harmLesscircleAnalysis = mainIndexChangService.recyclePolyline(homeRequestEntity);
        JSONObject jsonObject = JSONObject.parseObject(JSON.toJSONString(harmLesscircleAnalysis));
        returnData.setReturnData(jsonObject);
        return returnData;
    }

    /**
     * 回收利用饼状图
     */
    @PostMapping("/recyclepieChart")
    public BaseResponseDTO recyclepieChart(@RequestBody HomeRequestEntity homeRequestEntity) {
        BaseResponseDTO returnData = new BaseResponseDTO();
        MainIndexResponseEntity resourceAnalysis = mainIndexChangService.recyclepieChart(homeRequestEntity);
        JSONObject jsonObject = JSONObject.parseObject(JSON.toJSONString(resourceAnalysis));
        returnData.setReturnData(jsonObject);
        return returnData;
    }

    /**
     * 资源化分析
     */
    @PostMapping("/getResourceeAnalysis")
    public BaseResponseDTO getResourceeAnalysis(@RequestBody HomeRequestEntity homeRequestEntity) {
        BaseResponseDTO returnData = new BaseResponseDTO();
        MainIndexResponseEntity resourceCircleAnalysis = mainIndexChangService.getResourceeAnalysis(homeRequestEntity);
        JSONObject jsonObject = JSONObject.parseObject(JSON.toJSONString(resourceCircleAnalysis));
        returnData.setReturnData(jsonObject);
        return returnData;


    }

    /**
     * gis展示
     */
    @PostMapping("/gis")
    public BaseResponseDTO getGisAnalysis(@RequestBody HomeRequestEntity homeRequestEntity) {
        BaseResponseDTO returnData = new BaseResponseDTO();
        MainIndexResponseEntity gisAnalysis = mainIndexChangService.getGisAnalysis(homeRequestEntity);
        JSONObject jsonObject = JSONObject.parseObject(JSON.toJSONString(gisAnalysis));
        returnData.setReturnData(jsonObject);
        return returnData;
    }
}
